<?php

require("html2fpdf.php");
include("../core.php");

$language=$_COOKIE['lang'];


$htmlFile=$root_domain.(isset($_GET["page"])  ? $_GET["page"]: "");
$fileload=str_replace($name_pdf.".pdf","",$htmlFile)."/".$language.".htm";
if($htmlFile=="")
{
	echo "File not exist";
	exit();
}
$buffer = file_get_contents($fileload); 

if(!$buffer)
{
	$buffer = $err_pdf;
}
$buffer=substr($buffer,strpos($buffer,"<body"));
$buffer=str_replace("<a name=\"top\"></a>","",$buffer);

$pdf = new HTML2FPDF('P', 'mm', 'A4'); 
$pdf->AddPage(); 
$pdf->WriteHTML($buffer); 

$filename=str_replace("http://","",$htmlFile);
$filename=str_replace(dirname($filename)."/","",$filename);
$filename=str_replace(".htm","",$filename);

$pdf->Output($filename,'D'); 
?>